package com.finalministry.server;

import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;

public abstract class IndexBase {

	public String getIndexPage() throws IOException {
		return getPage("finalministry");
	}

	public String getAdvancedPage() throws IOException {
		return getPage("advanced");
	}

	public String getRedirectToIndexPage() throws IOException {
		return FileUtils.readFileToString(new File("src/main/resources/web/redirectToIndex.htm")).replaceAll("#PORT#",
				String.valueOf(FinalministryWebServer.portWebserver));
	}

	public String getPage(String page) throws IOException {
		return FileUtils.readFileToString(new File("src/main/resources/web/#PAGE#.htm".replaceAll("#PAGE#", page))).replaceAll("#HOME#",
				FinalministryWebServer.contentUrl);
	}
}